package jmine.tec.subscription.impl;

import jmine.tec.subscription.Publication;
import jmine.tec.subscription.Publisher;
import jmine.tec.subscription.SubscriptionSettings;

/**
 * Encaminha os eventos diretamente ao {@link SubscriptionManagerImplementor}. Este metodo eh preferivel sobre o
 * {@link ApplicationEventRouter} por ser mais rapido.
 * 
 * @author takeshi
 */
public final class DirectEventRouter implements EventRouter {

    private final SubscriptionManagerImplementor subscriptionManager;

    /**
     * C'tor
     * 
     * @param subscriptionManager o {@link SubscriptionManagerImplementor}
     */
    public DirectEventRouter(SubscriptionManagerImplementor subscriptionManager) {
        super();
        this.subscriptionManager = subscriptionManager;
    }

    /**
     * {@inheritDoc}
     */
    public <P extends Publication> void broadcast(SubscriptionSettings settings, Publisher<P> publisher, P publication) {
        this.subscriptionManager.localPublish(publisher, settings, publication);
    }

    /**
     * {@inheritDoc}
     */
    public <P extends Publication> void broadcastPartialPublication(SubscriptionSettings settings, Publisher<P> publisher,
            PartialPublication<P> partial) {
        this.subscriptionManager.broadcastPartialPublication(publisher, settings, partial);
    }

}
